<template>

    <el-menu
            :default-active="active"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b">
        <!--新增菜单模板-->
          <el-submenu index="1" :disabled="openFlag[0]">
              <template slot="title">
                  <i class="el-icon-s-management"></i>
                  <span>挂号</span>
              </template>
              <el-menu-item-group>
                  <template slot="title">挂号操作</template>
                  <el-menu-item index="1-1" @click="to('register')">挂号</el-menu-item>
                  <el-menu-item  index="1-2" @click="to('register_del')">退号</el-menu-item>
                  <el-menu-item  index="1-3"  @click="to('register_query')">统计</el-menu-item>
              </el-menu-item-group>
              <el-menu-item-group>
                  <template slot="title">费用管理</template>
                  <el-menu-item index="1-4" @click="to('checkApply_fee')">检查费用</el-menu-item>
                  <el-menu-item index="1-5" @click="to('prescription_Fee')">处方费用</el-menu-item>
              </el-menu-item-group>
          </el-submenu>

        <el-submenu index="2" :disabled="openFlag[1]">
            <template slot="title">
                <i class="el-icon-message-solid"></i>
                <span>门诊操作</span>
            </template>
            <el-menu-item-group>
                <el-menu-item index="2-1" @click="to('checkApply')">检查申请管理</el-menu-item>
                <el-menu-item index="2-2" @click="to('medicalRecord')">病历管理</el-menu-item>
                <el-menu-item index="2-3" @click="to('prescription')">开药管理</el-menu-item>
            </el-menu-item-group>
        </el-submenu>
        <el-submenu index="3" :disabled="openFlag[2]">
            <template slot="title">
                <i class="el-icon-first-aid-kit"></i>
                <span>门诊医技工作站</span>
            </template>
            <el-menu-item-group>
                <el-menu-item index="3-1" @click="to('check')" >检查</el-menu-item>
            </el-menu-item-group>
        </el-submenu>
        <el-submenu index="4" :disabled="openFlag[3]">
            <template slot="title">
                <i class="el-icon-menu"></i>
                <span>药房管理</span>
            </template>
            <el-menu-item-group>
                <el-menu-item index="4-1" @click="to('dispensing')" >药房发药</el-menu-item>
                <el-menu-item  index="4-2" @click="to('medicineReturn')" >药房退药</el-menu-item>
                <el-menu-item  index="4-3" @click="to('medicineManagement')" >药品管理</el-menu-item>
            </el-menu-item-group>
        </el-submenu>
        <el-submenu index="5" :disabled="openFlag[4]">
            <template slot="title">
                <i class="el-icon-s-management"></i>
                <span>后台</span>
            </template>
            <el-menu-item  index="5-1" @click="to('schedul')">医师管理</el-menu-item>
            <el-menu-item  index="5-2"  @click="to('rule')">排班方案</el-menu-item>
            <el-menu-item  index="5-3"  @click="to('docReg')">医师入职</el-menu-item>
        </el-submenu>


    </el-menu>
</template>

<script>
    import storage from 'good-storage'
    export default {
        data(){
            return{
                active:'1-1',
                openFlag:[true,true,true,true,true],
            }
        },
        created(){
          let user=storage.get("user")
            switch (user.useType) {
                case 0:
                    this.active="5-1"
                    this.openFlag[4]=false
                    break;
                case 1:
                    this.active="4-1"
                    this.openFlag[3]=false
                    break;
                case 2:
                    this.active="1-1"
                    this.openFlag[0]=false
                    break;
                case 3:
                    this.active="2-1"
                    this.openFlag[1]=false
                    this.openFlag[2]=false
                    break;
                case 4:
                    this.active="1-1"
                    this.openFlag=[false,false,false,false,false]
                    break;

            }
        },
        methods:{
            to(toName){
                this.$router.push("/"+toName);
            },
            handleOpen(key, keyPath) {
                // eslint-disable-next-line no-console
                console.log(key, keyPath);
            },
            handleClose(key, keyPath) {
                // eslint-disable-next-line no-console
                console.log(key, keyPath);
            }
        },
        mounted(){
                this.$router.push("/register")
        }

    }
</script>

<style scoped>
</style>